package com.hunk.core.aop;

import java.util.Date;

import javax.servlet.http.HttpSession;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;

import com.hunk.core.Constants;
import com.hunk.core.web.ControllerContext;
import com.hunk.utils.io.Print;

@Component
public class ActionTraceAspect {
	
	@Before("@annotation(com.hunk.core.annotation.ActionTrace)")
	public void actionTrace(JoinPoint jp) {
		HttpSession session = ControllerContext.getContext().getSession();
		String methodName = jp.getSignature().getName();
		Print.print(" User:" + session.getAttribute(Constants.LOGIN_USERNAME.name()));
	    Print.print(", Call method: " + methodName);  
	    Print.print(", On " + new Date());
	}
}
